﻿// This software is the confidential and proprietary information of NetBay.
// Such confidential information should not be disclosed.
// NetBay copyright(c) 2012

#region

using System;
using NetBay.Core.Log;
using Rio.Workflow.Runtime.Enums;

#endregion

namespace Rio.Workflow.Runtime.Actions
{
    public class VentilateAction : WorkflowActionContext
    {
        #region Instance Methods

        /// <summary>
        /// Actions the executed.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public override ActionResult ActionExecuted(WorkflowContextBase context, ActionRequest request)
        {
            ActionResult result = ActionResult.Faulted;
            try
            {
                if (Ventilate(context, request))
                    result = ActionResult.Executed;
                else
                    result = ActionResult.Faulted;
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogDebugFormat("Execute error - " + ex.Message);
                throw;
            }

            return result;
        }

        /// <summary>
        /// Actions the executed all.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public override ActionResult ActionExecutedAll(WorkflowContextBase context, ActionRequest request)
        {
            ActionResult result = ActionResult.Faulted;
            try
            {
                if (Ventilate(context, request))
                    result = ActionResult.Executed;
                else
                    result = ActionResult.Faulted;
            }
            catch (Exception ex)
            {
                LogManager.Instance().LogDebugFormat("ExecuteAll error - " + ex.Message);
                throw;
            }

            return result;
        }

        /// <summary>
        /// Actions the executing.
        /// </summary>
        /// <param name="wkfContext">The WKF context.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public override ActionResult ActionExecuting(WorkflowContextBase wkfContext, ActionRequest request)
        {
            return ActionResult.NotSupported;
        }

        /// <summary>
        /// Actions the executing all.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public override ActionResult ActionExecutingAll(WorkflowContextBase context, ActionRequest request)
        {
            return ActionResult.NotSupported;
        }

        #endregion
    }
}